package 富婆梦.第一阶段.第八周Scoket.练习题;

/**
 * @ProjectName: java-learning
 * @Package: 富婆梦.第一阶段.第八周Scoket.练习题
 * @ClassName: RunThreads
 * @Author: hemengjin
 * @Description: 线程使用方法demo
 * @Date:2021/9/23 10:55
 * @Version: 1.0
 */
public class RunThreads implements Runnable{

    public static void main(String[] args) {
        //创建Runnable实例
        RunThreads runner = new RunThreads();
        Thread alpha = new Thread(runner);
        Thread beta = new Thread(runner);
        alpha.setName("alpha Thread");
        beta.setName("beta Thread");
        alpha.start();
        beta.start();
    }

    @Override
    public void run() {
        for (int i=0;i<35;i++){
            String threadName = Thread.currentThread().getName();
            System.out.println(threadName+" is running");
        }
    }
}
